package com.example.a22310.myapplication.Beans;

import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.databinding.BindingAdapter;
import android.view.View;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;

import java.io.Serializable;
import java.util.List;

import static com.example.a22310.myapplication.GloableClass.Yuejian.IMG_URL;

public class Prize {
    /**
     * code : 200
     * prizelist : [{"prizeid":"2","clubid":"2","pic":"11.jpg","name":"高档瑜伽垫","intro":"家居好选择","price":"1000","flag":"1"},{"prizeid":"4","clubid":"2","pic":"13.jpg","name":"高档瑜伽垫","intro":"家居好显泽","price":"1000","flag":"1"},{"prizeid":"1","clubid":"1","pic":"10.jpg","name":"跳绳计数器","intro":"与智能手表相连，关注成长","price":"500","flag":"0"},{"prizeid":"5","clubid":"3","pic":"14.jpg","name":"跳绳计数器","intro":"与智能手表相连，关注成长","price":"500","flag":"0"},{"prizeid":"3","clubid":"1","pic":"12.jpg","name":"高档瑜伽垫","intro":"家居好选择","price":"100","flag":"1"}]
     */

    private int code;
    private List<PrizelistBean> prizelist;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public List<PrizelistBean> getPrizelist() {
        return prizelist;
    }

    public void setPrizelist(List<PrizelistBean> prizelist) {
        this.prizelist = prizelist;
    }

    public static class PrizelistBean extends BaseObservable implements Serializable {
        /**
         * prizeid : 2
         * clubid : 2
         * pic : 11.jpg
         * name : 高档瑜伽垫
         * intro : 家居好选择
         * price : 1000
         * flag : 1
         */
        public PrizelistBean()
        {

        }

        public PrizelistBean(String prizeid,String userid, String clubid, String pic, String name,
                             String intro, String price,String flag)
        {
            this.prizeid = prizeid;
            this.userid = userid;
            this.clubid = clubid;
            this.clubid=clubid;
            this.pic =pic;
            this.name = name;
            this.intro=intro;
            this.price=price;
            this.flag =flag;
        }
        @BindingAdapter("pic")
        public static void loadInternetImage(ImageView iv, String pic) {
            pic = IMG_URL+pic;
            Picasso.with(iv.getContext()).load(pic).into(iv);
        }

        @Override
        public String toString() {
            return "PrizelistBean{" +
                    "prizeid='" + prizeid + '\'' +
                    "userid='" + userid + '\'' +
                    ", clubid='" + clubid + '\'' +
                    ", name='" + name + '\'' +
                    "pic='" + pic + '\'' +
                    "intro='" + intro + '\'' +
                    "price='" + price + '\'' +
                    ", flag='" + flag + '\'' +
                    '}';
        }

        public void onItemClick(View view){
//         Intent intent=new Intent(view.getContext(),OrderDetail.class);

            PrizelistBean prizelistBean = new  PrizelistBean();
            prizelistBean.setPrizeid(getPrizeid());
            prizelistBean.setUserid(getUserid());
            prizelistBean.setClubid(getClubid());
            prizelistBean.setName(getName());
            prizelistBean.setPic(getPic());
            prizelistBean.setIntro(getIntro());
            prizelistBean.setPrice(getPrice());
            prizelistBean.setFlag(getFlag());

//                intent.putExtra("Order", OrderlistBean);
//                view.getContext().startActivity(intent);
        }


        @Bindable






        private String prizeid;
        private String clubid;
        private String pic;
        private String userid;

        public String getUserid() {
            return userid;
        }

        public void setUserid(String userid) {
            this.userid = userid;
        }

        private String name;
        private String intro;
        private String price;
        private String flag;

        public String getPrizeid() {
            return prizeid;
        }

        public void setPrizeid(String prizeid) {
            this.prizeid = prizeid;
        }

        public String getClubid() {
            return clubid;
        }

        public void setClubid(String clubid) {
            this.clubid = clubid;
        }

        public String getPic() {
            return IMG_URL+pic;
        }

        public void setPic(String pic) {
            this.pic = pic;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getIntro() {
            return intro;
        }

        public void setIntro(String intro) {
            this.intro = intro;
        }

        public String getPrice() {
            return price;
        }

        public void setPrice(String price) {
            this.price = price;
        }

        public String getFlag() {
            return flag;
        }

        public void setFlag(String flag) {
            this.flag = flag;
        }
    }
}

